#include <Driver.h>

#include <string>
#include <map>
#include <stdexcept>

namespace CExpert{
    namespace{
        typedef std::map<std::string, is_alive_fn> is_alivers_t;
        is_alivers_t is_alivers;
    }

    int register_driver(const std::string& name, is_alive_fn fn){
        is_alivers[name] = fn;
        return 1;
    }

    is_alive_fn get_driver(const std::string& name){
        is_alivers_t::const_iterator it = is_alivers.find(name);
        if (it == is_alivers.end())
            throw DBCheckerException(std::string("unknown driver: ") + name);
        return it->second;
    }
}
